package org.lonetree.tc.webapp.actions;

import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.lonetree.tc.core.CourseComment;
import org.lonetree.tc.core.dao.CourseDAO;
import org.lonetree.tc.core.dao.DAOFactory;

public class AdminReportedComment extends AdminAction {

	@Override
	protected ActionForward executeAdmin(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		try{
			
			DAOFactory factory = DAOFactory.getDAOFactory(DAOFactory.FactoryImplementation.DB_DAO_FACTORY);
			CourseDAO cdao = factory.getCourseDAO();
			Set<CourseComment> comments=cdao.getFlaggedCourseComments();
		
			
			CourseComment c = (CourseComment)(comments.toArray()[0]);
			c.getParentCourse().getComments().remove(c);
			
			request.setAttribute("coursecomment", comments);

			//TODO Implement modfiy comment
			return mapping.findForward("success");
		}
		
		
		catch (Exception e){
			return mapping.findForward("failure");
		}
		
	}

}
